<!doctype html>
<html class="signup no-js" lang="${lang!}">

<head>
    <!-- meta -->
    <meta charset="utf-8">
    <meta name="description" content="Aebiz, Baseframework, Wizzer">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, maximum-scale=1">
    <!-- /meta -->

    <title>${app_name!}</title>

    <link rel="stylesheet" href="${base!}/assets/platform/vendor/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="${base!}/assets/platform/styles/font-awesome.css">
    <link rel="stylesheet" href="${base!}/assets/platform/styles/themify-icons.css">
    <link rel="stylesheet" href="${base!}/assets/platform/styles/animate.css">
    <link rel="stylesheet" href="${base!}/assets/platform/styles/main.css">

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
    <script src="${base!}/assets/platform/scripts/html5shiv.min.js"></script>
    <script src="${base!}/assets/platform/scripts/respond.min.js"></script>
    <script src="${base!}/assets/platform/scripts/json.js"></script>
    <![endif]-->

    <script src="${base!}/assets/platform/vendor/modernizr.js"></script>
    <script src="${base!}/assets/platform/vendor/jquery/jquery.min.js"></script>
    <script src="${base!}/assets/common/vendor/sso/RSA.js"></script>
    <script src="${base!}/assets/common/vendor/sso/BigInt.js"></script>
    <script src="${base!}/assets/common/vendor/sso/Barrett.js"></script>
</head>


<body class="bg-primary">

<div class="cover" style="background-image: url(${base!}/assets/platform/images/cover3.jpg)"></div>

<div class="overlay bg-primary"></div>

<div class="center-wrapper">
    <div class="center-content">
        <div class="row no-m">
            <div class="col-xs-10 col-xs-offset-1 col-sm-6 col-sm-offset-3 col-md-4 col-md-offset-4">
                <section class="panel bg-white no-b">
                    <div class="active text-center" style="font-size: 30px;padding: 10px;">${app_name!}
                    </div>
                    <div class="p15">
                        <form id="loginForm" action="${base!}/platform/login/doLogin" data-parsley-validate=""
                              novalidate=""
                              role="form"
                              method="post">
                            <input type="hidden" id="captcha" name="captcha">
                            <input id="username" name="username" type="text" value="${loginname!}" required
                                   class="form-control input-lg mb25" placeholder="${msg['sys.login.username']}"
                            <!--#if(isEmpty(loginname)){#-->autofocus<!--#}#-->>
                            <input id="password" name="password" type="password" required
                                   class="form-control input-lg mb25" placeholder="${msg['sys.login.password']}"
                            <!--#if(!isEmpty(loginname)){#-->autofocus<!--#}#-->>
                            <div class="show">
                                <label class="checkbox">
                                    <input name="rememberme" type="checkbox" value="1" <!--#if(!isEmpty(loginname)){#-->
                                    checked<!--#}#-->>${msg['sys.login.remember']}
                                </label>
                            </div>
                            <p id="tip" class="bg-danger p15" style="display:none"></p>
                            <button id="login" class="btn btn-primary btn-lg btn-block" type="button"
                                    data-loading-text="${msg['sys.login.submit']}...">${msg['sys.login.login']}
                            </button>
                        </form>
                    </div>
                </section>
                <p class="text-center">
                    Copyright &copy;
                    <span id="year" class="mr5"></span>
                </p>
            </div>
        </div>

    </div>
</div>
<!-- 验证码 -->
<div id="dialogVeryCode" class="modal fade bs-modal-sm" tabindex="-3" role="dialog" aria-hidden="false">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title" style="color:black;">
                    ${msg['sys.login.verifycode']}
                </h4>
            </div>
            <div class="modal-body">
                <form id="f2" onsubmit="return false;" data-parsley-validate="" novalidate="">
                    <div class="row">
                        <div class="col-xs-2"></div>
                        <div class="col-xs-6">
                            <input type="text" id="verifycode" required class="form-control input-lg"
                                   placeholder="${msg['sys.login.captcha']}">
                        </div>
                        <div class="col-xs-4">
                            <img id="captcha_img" src="${base!}/platform/login/captcha"
                                 style="height:46px;cursor: pointer;"
                                 onclick="$('#captcha_img').attr('src', '${base!}/platform/login/captcha?_=' + new Date().getTime())"/>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button id="ok" type="button" class="btn btn-primary" data-dismiss="modal">
                    ${msg['sys.login.captchasubmit']}
                </button>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    function bodyRSA()
    {
        setMaxDigits(200);
        return new RSAKeyPair("${platformPublicKeyExponent!'10001'}","","${platformPublicKeyModulus!'a5aeb8c636ef1fda5a7a17a2819e51e1ea6e0cceb24b95574ae026536243524f322807df2531a42139389674545f4c596db162f6e6bbb26498baab074c036777'}");
    }
    var key =  bodyRSA();
    $(function () {
        $("#year").html(new Date().getFullYear());
        $("#login").on("click",function () {
            $("#password").val(encryptedString(key,$("#password").val().split("").reverse().join("")));
            $("#loginForm").submit();
        });
        $("#loginForm").ajaxForm({
            dataType: 'json',
            beforeSubmit: function (arr, form, options) {
                form.find("button:submit").text("${msg['sys.login.login']}");
                form.find("button:submit").attr("disabled", "disabled");
            },
            success: function (data, statusText, xhr, form) {
                if (data.code == 0) {
                    $("#tip").hide();
                    form.find("button:submit").text("${msg['sys.login.success']}");
                    window.location.href = "${base!}/platform/home";
                } else if (data.code == 2) {
                    $("#verifycode").val("");
                    $("#dialogVeryCode img").attr("src", '${base!}/platform/login/captcha?_=' + new Date().getTime());
                    return $("#dialogVeryCode").modal({show: true, backdrop: 'static', keyboard: false});
                } else {
                    $("#captcha").val("");
                    $("#password").val("").focus();
                    $('#captcha_img').attr('src', '${base!}/platform/login/captcha?_=' + new Date().getTime());
                    $("#tip").html(data.msg);
                    $("#tip").fadeIn();
                    form.find("button:submit").text("${msg['sys.login.login']}");
                    form.find("button:submit").removeAttr("disabled")
                }
            }
        });
        $("#ok").on("click", function () {
            if ($("#verifycode").val() == "") {
                $("#f2").submit();
                return false;
            }
            $("#captcha").val($("#verifycode").val());
            $("#loginForm").submit();
        });
        $("#dialogVeryCode").on("keypress", function (event) {
            var key = event.which;
            if (key == 13) {
                $("#ok").trigger("click");
            }
        });
    });
</script>
</body>
<script src="${base!}/assets/platform/vendor/bootstrap/js/bootstrap.min.js"></script>
<script src="${base!}/assets/platform/vendor/jquery.form/jquery.form.js"></script>
<script src="${base!}/assets/platform/vendor/parsleyjs/parsley.min.js"></script>
<script src="${base!}/assets/platform/vendor/parsleyjs/locale/${lang!'zh_CN'}.js"></script>
</html>
